package com.chong.foundation;

public class Calculation02 {
    public static void main(String[] args) {
        // java运算
        //2. 赋值运算符

        // 赋值(=)
        int a = 10, b = 20;
        System.out.println("a: " + a + ", b: " + b); //a: 10, b: 20

        // 字符串类型也可以进行 加法赋值
        String c = "hello", d = "world";
        c += d;
        System.out.print(c + "\n"); //helloworld


        //加法赋值（+=）
        int a1 = 10, b1 = 20;
        a1 += b1;
        System.out.print(a1 + "\n"); //30


        //减法赋值（-=）
        int c1 = 20, d1 = 10;
        c1 -= d1;
        System.out.print(c1 + "\n"); //10


        //乘法赋值（*=）
        int c2 = 10, d2 = 10;
        c2 *= d2;
        System.out.print(c2 + "\n"); //100


        //除法赋值 （/=）
        int c3 = 100, d3 = 20;
        c3 /= d3;
        System.out.print(c3 + "\n"); //5


        //取模赋值(%=)
        int c4 = 80, d4 = 30;
        c4 %= d4;
        System.out.print(c4); // 20
    }
}
